brandata

Brightcells 5 years ago
parent
commit
8f8e010c28
2 changed files with 9 additions and 7 deletions
  1. 6 4
      account/models.py
  2. 3 3
      miniapp/views.py

+ 6 - 4
account/models.py

@@ -392,9 +392,10 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin):
392 392
             }
393 393
         ]
394 394
 
395
-    def srinfo(self, brand_id=None):
395
+    @property
396
+    def srinfo(self):
396 397
         try:
397
-            sr = SalesResponsibilityInfo.objects.get(brand_id=brand_id, unionid=self.unionid, user_status=SalesResponsibilityInfo.ACTIVATED)
398
+            sr = SalesResponsibilityInfo.objects.get(brand_id=self.brand_id, unionid=self.unionid, user_status=SalesResponsibilityInfo.ACTIVATED)
398 399
         except SalesResponsibilityInfo.DoesNotExist:
399 400
             sr = None
400 401
         return sr.base_data if sr else {
@@ -403,7 +404,8 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin):
403 404
             'is_super_sr': False,
404 405
         }
405 406
 
406
-    def brandata(self, brand_id=None):
407
+    @property
408
+    def brandata(self):
407 409
         if self.clerk_id:
408 410
             try:
409 411
                 saleclerk = SaleclerkInfo.objects.get(clerk_id=self.clerk_id, status=True)
@@ -426,7 +428,7 @@ class UserInfo(BaseModelMixin, LensmanTypeBoolMixin):
426 428
             'cardList': self.cardList,
427 429
             'saleclerk': bool(saleclerk_info),
428 430
             'saleclerk_info': saleclerk_info,
429
-            'sr_info': self.srinfo(brand_id),
431
+            'sr_info': self.srinfo,
430 432
         }
431 433
 
432 434
     @property

+ 3 - 3
miniapp/views.py

@@ -87,7 +87,7 @@ def get_userinfo_api(request):
87 87
     # Just for compatible because of store session_key has changed
88 88
     store_session_key(appid=appid, secret=secret, session_key=session_key, unid='', storage=RedisStorage(r))
89 89
 
90
-    return response(200, 'Mini App Login Success', u'微信小程序登录成功', user.brandata(brand_id=brand_id))
90
+    return response(200, 'Mini App Login Success', u'微信小程序登录成功', user.brandata)
91 91
 
92 92
 
93 93
 @logit(res=True)
@@ -161,7 +161,7 @@ def mini_login_api(request):
161 161
     # Just for compatible because of store session_key has changed
162 162
     store_session_key(appid=appid, secret=secret, session_key=session_key, unid='', storage=RedisStorage(r))
163 163
 
164
-    return response(200, 'Mini App Login Success', u'微信小程序登录成功', user.brandata(brand_id=brand_id))
164
+    return response(200, 'Mini App Login Success', u'微信小程序登录成功', user.brandata)
165 165
 
166 166
 
167 167
 @logit
@@ -211,7 +211,7 @@ def get_userinfo_api2(request):
211 211
     # Store Userinfo
212 212
     set_profile_info(user)
213 213
 
214
-    return response(200, 'Mini App Get Userinfo Success', u'微信小程序获取用户信息成功', user.brandata(brand_id=brand_id))
214
+    return response(200, 'Mini App Get Userinfo Success', u'微信小程序获取用户信息成功', user.brandata)
215 215
 
216 216
 
217 217
 @logit(res=True)